import java.util.Scanner;
class Student{
    private String studentName;
    private int studentAge;
    private String studentGander;
    public String name;
    public int age;
    public Student(){}
    public Student(String studentName,int studentAge,String studentGander){
        this.studentName = studentName;
        this.studentAge = studentAge;
        this.studentGander = studentGander;
    }
    public void setStudentName(String studentName){
        this.studentName = studentName;
    }
    public String getStudentName(){
        return this.studentName;
    }
    public void setStudentAge(int studentAge){
        this.studentAge = studentAge;
    }
    public int getStudentAge(){
        return this.studentAge;
    }
    public void setStudentGander(String studentGander){
        this.studentGander = studentGander;
    }
    public String getStudentGander(){
        return this.studentGander;
    }
    public void printStudentManagement(){
        System.out.println("name:" + this.studentName + "    age:" + this.studentAge + "    gander:" + this.studentGander);
    }
    public void sayHello() {
        // TODO Auto-generated method stub
        throw new UnsupportedOperationException("Unimplemented method 'sayHello'");
    }
}
class StudentManagement{
    private Student [] stuArr;
    private int count;
    private Scanner in;
    public StudentManagement(){
        stuArr = new Student[100];
        in = new Scanner(System.in);
    }
    public StudentManagement(int size){
        stuArr = new Student[size];
        in = new Scanner(System.in);
    }
    public void showMenu(){
        System.out.println("********************");
        System.out.println("*Student Management*");
        System.out.println("********************");
        System.out.println("* 1)Add");
        System.out.println("* 2)Delete");
        System.out.println("* 3)Update");
        System.out.println("* 4)Select");
        System.out.println("* 5)SelectAll");
        System.out.println("* 0)Quit");
        System.out.println("********************");
        System.out.print("Please choose your operate:");
    }
    private int findStudent(){
        int index = -1;
        String name;
        System.out.println("Please input name:");
        name = in.next();
        for(int i = 0;i < count;i++){
            if(name.equals(stuArr[i].getStudentName())){
                index = i;
                break;
            }
        }
        return index;
    }
    public void addStudent(){
        String studentName;
        int studentAge;
        String studentGander;
        Student stu;
        if(count >= stuArr.length){
            System.out.println("failure");
            return;
        }
        System.out.println("Please input name:");
        studentName = in.next();
        System.out.println("Please input age:");
        studentAge = in.nextInt();
        System.out.println("Please input gander:");
        studentGander = in.next();
        stu = new Student(studentName,studentAge,studentGander);
        stuArr[count] = stu;
        count++;
        System.out.println("Add student success");
    }
    public void deleteStudent(){
        int index = findStudent();
        if(index != -1){
            for(int i = index;i < stuArr.length - 1;i++){
                stuArr[index] = stuArr[index + 1];
            }
            stuArr[stuArr.length - 1] = null;
            count--;
            System.out.println("Delete student success");
        }else{
            System.out.println("cannot find this student");
        }
    }
    public void updateStudent(){
        String studentName;
        int studentAge;
        String studentGander;
        int index = findStudent();
        if(index != -1){
            Student stu = stuArr[index];
            System.out.println("Please input name:");
            studentName = in.next();
            stu.setStudentName(studentName);
            System.out.println("Please input age:");
            studentAge = in.nextInt();
            stu.setStudentAge(studentAge);
            System.out.println("Please input gander:");
            studentGander = in.next();
            stu.setStudentGander(studentGander);
            System.out.println("Update student success");
        }else{
            System.out.println("cannot find this student");
        }

    }
    public void selectStudent(){
        int index = findStudent();
        if(index != -1){
            Student stu = stuArr[index];
            stu.printStudentManagement();
        }else{
            System.out.println("cannot find this student");
        }
    }
    public void selectAllStudent(){
        for(int i = 0;i < count;i++){
            Student stu = stuArr[i];
            stu.printStudentManagement();
        }
    }
}
public class StudentTest{
    public static void main(String[] args){
        StudentManagement sm = new StudentManagement();
        int option = -1;
        Scanner sc = new Scanner(System.in);
        sc.close();
        Loop: while(true){
            sm.showMenu();
            option = sc.nextInt();
            if(option < 0 || option >5){
                continue;
            }
            switch(option){
                case 1: sm.addStudent();        break;
                case 2: sm.deleteStudent();     break;
                case 3: sm.updateStudent();     break;
                case 4: sm.selectStudent();     break;
                case 5: sm.selectAllStudent();  break;
                case 0: break Loop;
            }
        }
        System.out.println("over,bye!");
    }
}